package com.bit.ioc;

import com.bit.ioc.component.UserComponent;
import com.bit.ioc.config.UserConfig;
import com.bit.ioc.controller.HelloController;
import com.bit.ioc.modle.Student;
import com.bit.ioc.rep.UserRepons;
import com.bit.ioc.service.UserService;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
public class DemoApplication {

	public static void main(String[] args) {
//		ApplicationContext context=
	SpringApplication.run(DemoApplication.class, args);
		//方法一：通过类型进行获取对象的方法；
//		HelloController Bean=context.getBean(HelloController.class);
//		Bean.print();
//		//方法二：通过名字进行获取对象的方法；
//		HelloController Bean2= (HelloController) context.getBean("helloController");
//		Bean2.print();
//		//方法三：通过名字和类型进行获取对象和方法；
//		HelloController Bean3=context.getBean("helloController",HelloController.class);
//		Bean3.print();
//		//进行确定这三个方法获取的对象是否是同一个对象；
//		System.out.println(Bean);
//		System.out.println(Bean2);
//		System.out.println(Bean3);
//		UserService userService=context.getBean(UserService.class);
//		userService.print();
//		UserComponent userComponent=context.getBean(UserComponent.class);
//		userComponent.print();
//		UserRepons userRepons=context.getBean(UserRepons.class);
//		userRepons.print();
//		UserConfig userConfig=context.getBean(UserConfig.class);
//		userConfig.print();
//		//@bean的使用
//		Student student= (Student) context.getBean("s1");
//		System.out.println(student);
//
//		UserService userService=context.getBean(UserService.class);
//		userService.print();


	}

}
